import type { User } from "@/interface/User";
import type {Select} from "@/interface/Select";
import {onMounted, ref, watchEffect} from "vue"
import {bindSelectApi} from "@/controller/PropertyApi";
import type {Rule} from "ant-design-vue/es/form";

export  default  function (user : User) {

    let propertyData = ref<Select[]>([]);


    onMounted(()=> {
        getBindSelect();
    });

    function getBindSelect(keyWord? : string) {
        bindSelectApi(keyWord).then(res => {
            propertyData.value = res.data;
        })
    }

    const filterPropertyOption = (input: string, option: any) => {
        return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
    };

    let formRef = ref();

    let rules : Record<string, Rule[]> = {
        propertyId: [ {required: true, message: '请选择物业进行绑定', trigger: 'blur'} ]
    }



    return {
        propertyData, filterPropertyOption , formRef , rules
    }
}
